local skel = fk.CreateSkill{
  name = "#rmt_global_trigger",
  mode_skill = true,
}

Fk:loadTranslationTable{
  ["#RmtPileRemove"] = "%card 被替换",
}

local DIY = require "packages.diy_utility.diy_utility"

skel:addEffect(fk.GamePrepared, {
  global = true,
  mute = true,

  can_refresh = Util.TrueFunc,
  on_refresh = function (self, event, target, player, data)
    local room = player.room
    -- 若不为国战，且开启了封侯卡牌包
    if player.seat == 1 and not string.find(room:getSettings('gameMode'), "heg")
    and not table.contains(room.disabled_packs, "rmt_cards") then
      local remove_list = { "crossbow", "halberd", "blade" }
      local ids = table.filter(room.draw_pile, function (id)
        return table.contains(remove_list, Fk:getCardById(id, true).name)
      end)
      if #ids > 0 then
        room:sendLog{ type = "#RmtPileRemove", card = ids }
        room:moveCardTo(ids, Card.Void, nil, fk.ReasonJustMove, skel.name)
      end
    end
    if not string.find(room:getSettings('gameMode'), "aaa_role_mode") and not string.find(room:getSettings('gameMode'), "heg") then
    -- 非身份局游戏开始时，隐匿角色进入隐匿。且势力改为none
      local skills = Fk.generals[player.general]:getSkillNameList()
      if Fk.generals[player.deputyGeneral] then
        table.insertTable(skills, Fk.generals[player.deputyGeneral]:getSkillNameList())
      end
      if player.general ~= "hiddenone" and table.find(skills, function (s) return Fk.skills[s]:hasTag(Skill.Hidden) end) then
        room:setPlayerProperty(player, "shield", 0)--清空初始护甲
        DIY.enterHidden(player)
      end
      if player.general == "hiddenone" and player.kingdom ~= "none" then
        room:setPlayerProperty(player, "kingdom", "none")
      end
    end
  end,
})

--- 禁止触发此时机
skel:addEffect(fk.AfterCardsMove, {
  global = true,
  mute = true,
  can_trigger = function (self, event, target, player, data)
    return table.find(data, function (move)
      return move.skillName == skel.name
    end)
  end,
  on_trigger = Util.TrueFunc,
})


return skel
